<template>
  <div class="content">
    <!-- 1.IP暗噪声:------------------------------------------------------------------------ -->
    <div id="table1">
      <div class="innertitle" style="position: relative;">
        1.IP暗噪声:
        <span style="position: absolute; right: 0px;"><i>$\alpha = arctan \pmatrix{x \over h}$</i></span>
      </div>
      <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
        <tr>
          <td>IP尺寸,in</td>
          <td>IP板序列编号</td>
          <td>影像质量</td>
          <td>暗噪声指示值</td>
          <td>厂家保证值</td>
        </tr>
        <tr>
          <td>
            <el-input v-model="form1.dimension_1_width" class="input-line" /> x <el-input v-model="form1.dimension_1_height" class="input-line" />
          </td>
          <td><el-input v-model="form1.boardNumber_1" /></td>
          <td>
            <el-radio v-model="form1.quality_1" :label="1">全野清晰、均匀一致，无伪影</el-radio>
            <el-radio v-model="form1.quality_1" :label="2">不均匀一致或有伪影</el-radio>
          </td>
          <td><el-input v-model="form1.indicatedValue_1" /></td>
          <td rowspan="3"><el-input v-model="form1.guaranteedValue" /></td>
        </tr>
        <tr>
          <td>
            <el-input v-model="form1.dimension_2_width" class="input-line" /> x <el-input v-model="form1.dimension_2_height" class="input-line" />
          </td>
          <td><el-input v-model="form1.boardNumber_2" /></td>
          <td>
            <el-radio v-model="form1.quality_2" :label="1">全野清晰、均匀一致，无伪影</el-radio>
            <el-radio v-model="form1.quality_2" :label="2">不均匀一致或有伪影</el-radio>
          </td>
          <td><el-input v-model="form1.indicatedValue_2" /></td>
        </tr>
        <tr>
          <td>
            <el-input v-model="form1.dimension_3_width" class="input-line" /> x <el-input v-model="form1.dimension_3_height" class="input-line" />
          </td>
          <td><el-input v-model="form1.boardNumber_3" /></td>
          <td>
            <el-radio v-model="form1.quality_3" :label="1">全野清晰、均匀一致，无伪影</el-radio>
            <el-radio v-model="form1.quality_3" :label="2">不均匀一致或有伪影</el-radio>
          </td>
          <td><el-input v-model="form1.indicatedValue_3" /></td>
        </tr>
      </table>
    </div>

    <!-- 2.探测器剂量指示(DDI):------------------------------------------------------------------------ -->
    <div id="table2" style="margin-top: 20px;">
      <div class="innertitle" style="position: relative;">
        2.探测器剂量指示(DDI):
        <span style="position: absolute; right: 0px; top: 5px;">
          <i>$单板偏差 = {K_{响应} - K_{测量} \over K_{测量}} \times 100\%$</i>
          <span style="margin: 0 20px;"></span>
          <i>$多板偏差 = {K_{响应} - \overline K_{响应} \over K_{响应}} \times 100\%$</i>
        </span>
      </div>
      <div class="tip-30">
        预置条件:
        <el-input v-model="form2.tubeVoltage" class="input-line"/>kV
        <el-input v-model="form2.tubeCurrent" class="input-line"/>mAs
        <el-input v-model="form2.readoutValue" class="input-line"/>μGy
        <span style="margin-left: 50px;">SID：</span>
        <el-input v-model="form2.sid" class="input-line"/>cm
        <span style="margin-left: 50px;">附加滤过:0.5mmCu+1mmAl</span>
      </div>
      <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
        <tr>
          <td>IP尺寸,in</td>
          <td>IP板序列编号</td>
          <td>剂量指示值（<el-input v-model="form2.measurementUnit" class="input-line" />）</td>
          <td>响应空气比释动能<i>$K_{响应}$</i></td>
          <td>单板偏差,%</td>
          <td>多板偏差,%</td>
        </tr>
        <tr>
          <td>
            <el-input v-model="form2.dimension_1_width" class="input-line" /> x <el-input v-model="form2.dimension_1_height" class="input-line" />
          </td>
          <td><el-input v-model="form2.boardNumber_1" /></td>
          <td><el-input v-model="form2.valueDose_1" /></td>
          <td><el-input v-model="form2.kerma_1" /></td>
          <td><el-input v-model="form2.singleDeviation_1" /></td>
          <td><el-input v-model="form2.moreDeviation_1" /></td>
        </tr>
        <tr>
          <td>
            <el-input v-model="form2.dimension_2_width" class="input-line" /> x <el-input v-model="form2.dimension_2_height" class="input-line" />
          </td>
          <td><el-input v-model="form2.boardNumber_2" /></td>
          <td><el-input v-model="form2.valueDose_2" /></td>
          <td><el-input v-model="form2.kerma_2" /></td>
          <td><el-input v-model="form2.singleDeviation_2" /></td>
          <td><el-input v-model="form2.moreDeviation_2" /></td>
        </tr>
        <tr>
          <td>
            <el-input v-model="form2.dimension_3_width" class="input-line" /> x <el-input v-model="form2.dimension_3_height" class="input-line" />
          </td>
          <td><el-input v-model="form2.boardNumber_3" /></td>
          <td><el-input v-model="form2.valueDose_3" /></td>
          <td><el-input v-model="form2.kerma_3" /></td>
          <td><el-input v-model="form2.singleDeviation_3" /></td>
          <td><el-input v-model="form2.moreDeviation_3" /></td>
        </tr>
      </table>
    </div>

    <!-- 3.IP响应均匀性、4.IP响应一致性:------------------------------------------------------------------------ -->
    <div id="table3" style="margin-top: 30px;">
      <div class="innertitle" style="position: relative;">
        3.IP响应均匀性、4.IP响应一致性:
        <span style="position: absolute; right: 0px; top: 5px;">
          <i>$均匀性（最大偏差）= {测量值 - 平均值 \over 平均值} \times 100\%$</i>
          <span style="margin: 0 20px;"></span>
          <i>$一致性（最大偏差）= {单板平均值 - 总平均值 \over 总平均值} \times 100\%$</i>
        </span>
      </div>
      <div class="tip-30">
        预置条件:
        <el-input v-model="form3.tubeVoltage" class="input-line"/>kV
        <el-input v-model="form3.tubeCurrent" class="input-line"/>mAs
        <el-input v-model="form3.readoutValue" class="input-line"/>μGy
        <span style="margin-left: 50px;">SID：</span>
        <el-input v-model="form3.sid" class="input-line"/>cm
        <span style="margin-left: 50px;">附加滤过:0.5mmCu+1mmAl</span>
      </div>
      <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
        <tr>
          <td rowspan="2">IP尺寸,in</td>
          <td rowspan="2">IP板序列编号</td>
          <td colspan="5">
            <el-radio v-model="form3.boardType" :label="1">平均像素值</el-radio>
            <el-radio v-model="form3.boardType" :label="2">光密度</el-radio>
          </td>
          <td rowspan="2">均匀性%</td>
          <td rowspan="2">一致性%</td>
        </tr>
        <tr>
          <td>中心</td>
          <td>左上</td>
          <td>右上</td>
          <td>左下</td>
          <td>右下</td>
        </tr>
        <tr>
          <td rowspan="3">
            <el-input v-model="form3.dimension_width" class="input-line" /> x <el-input v-model="form3.dimension_height" class="input-line" />
          </td>
          <td><el-input v-model="form3.boardNumber_1" /></td>
          <td><el-input v-model="form3.middle_1" /></td>
          <td><el-input v-model="form3.left_up_1" /></td>
          <td><el-input v-model="form3.right_up_1" /></td>
          <td><el-input v-model="form3.left_down_1" /></td>
          <td><el-input v-model="form3.right_down_1" /></td>
          <td><el-input v-model="form3.uniformity_1" /></td>
          <td rowspan="3"><el-input v-model="form3.consistence" /></td>
        </tr>
        <tr>
          <td><el-input v-model="form3.boardNumber_2" /></td>
          <td><el-input v-model="form3.middle_2" /></td>
          <td><el-input v-model="form3.left_up_2" /></td>
          <td><el-input v-model="form3.right_up_2" /></td>
          <td><el-input v-model="form3.left_down_2" /></td>
          <td><el-input v-model="form3.right_down_2" /></td>
          <td><el-input v-model="form3.uniformity_2" /></td>
        </tr>
        <tr>
          <td><el-input v-model="form3.boardNumber_3" /></td>
          <td><el-input v-model="form3.middle_3" /></td>
          <td><el-input v-model="form3.left_up_3" /></td>
          <td><el-input v-model="form3.right_up_3" /></td>
          <td><el-input v-model="form3.left_down_3" /></td>
          <td><el-input v-model="form3.right_down_3" /></td>
          <td><el-input v-model="form3.uniformity_3" /></td>
        </tr>
      </table>
    </div>

    <!-- 5.IP响应线性:------------------------------------------------------------------------ -->
    <div id="table4" style="margin-top: 30px;">
      <div class="innertitle" style="position: relative;">
        5.IP响应线性:
        （<el-checkbox v-model="form4.notHave">状态检测无此项</el-checkbox>）
        <span style="font-weight: normal;">管电压:<el-input v-model="form4.tubeVoltage" class="input-line"/>kV</span>
        <span style="margin-left: 50px; font-weight: normal;">SID：<el-input v-model="form4.sid" class="input-line"/>cm</span>
        <span style="position: absolute; right: 0px; top: 5px;">
          <i>$线性（偏差） = {K_{响应} - K_{测量} \over K_{测量}} \times 100\%$</i>
        </span>
      </div>
      <div class="tip-30">
        IP尺寸（in）：
        <el-input v-model="form4.dimension_width" class="input-line"/> x 
        <el-input v-model="form4.dimension_height" class="input-line"/>
        IP板序列编号： 
        <el-input v-model="form4.boardNumber" class="input-line"/>
        <span style="margin-left: 50px;">附加滤过:0.5mmCu+1mmAl</span>
      </div>
      <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
        <tr>
          <td>预置条件mAs</td>
          <td>测量值μGy</td>
          <td>校准因子</td>
          <td>校准值μGy</td>
          <td>剂量指示值（<el-input v-model="form4.valueDoseUnit" class="input-line" />）</td>
          <td>响应空气比释动能<i>$K_{响应}$</i>,μGy</td>
          <td>线性,%</td>
        </tr>
        <tr>
          <td><el-input v-model="form4.milliampereSecond_1" /></td>
          <td><el-input v-model="form4.measurementValue_1" /></td>
          <td><el-input v-model="form4.calibrationFactor_1" /></td>
          <td><el-input v-model="form4.calibrationValue_1" /></td>
          <td><el-input v-model="form4.valueDose_1" /></td>
          <td><el-input v-model="form4.kerma_1" /></td>
          <td><el-input v-model="form4.doseLinearity_1" /></td>
        </tr>
        <tr>
          <td><el-input v-model="form4.milliampereSecond_2" /></td>
          <td><el-input v-model="form4.measurementValue_2" /></td>
          <td><el-input v-model="form4.calibrationFactor_2" /></td>
          <td><el-input v-model="form4.calibrationValue_2" /></td>
          <td><el-input v-model="form4.valueDose_2" /></td>
          <td><el-input v-model="form4.kerma_2" /></td>
          <td><el-input v-model="form4.doseLinearity_2" /></td>
        </tr>
        <tr>
          <td><el-input v-model="form4.milliampereSecond_3" /></td>
          <td><el-input v-model="form4.measurementValue_3" /></td>
          <td><el-input v-model="form4.calibrationFactor_3" /></td>
          <td><el-input v-model="form4.calibrationValue_3" /></td>
          <td><el-input v-model="form4.valueDose_3" /></td>
          <td><el-input v-model="form4.kerma_3" /></td>
          <td><el-input v-model="form4.doseLinearity_3" /></td>
        </tr>
      </table>
    </div>

    <!-- 6.测距误差:------------------------------------------------------------------------ -->
    <div id="table5">
      <div class="innertitle" style="position: relative;">
        6.测距误差:
        <span style="position: absolute; right: 0px; top: 20px;"><i>$E = {D_m - D_o \over D_o} \times 100\%$</i></span>
      </div>
      <div class="tip-30">
        预置条件:
        <el-input v-model="form5.tubeVoltage" class="input-line"/>kV
        <el-input v-model="form5.tubeCurrent" class="input-line"/>mAs
        <span style="margin-left: 50px;">SID：</span>
        <el-input v-model="form5.sid" class="input-line"/>cm
        <span style="margin-left: 50px;">附加滤过:</span>
        <el-input v-model="form5.extraFiltration" class="input-line"/>
      </div>
      <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
        <tr>
          <td>测量方向</td>
          <td>测量距离<i>$D_m$</i>，mm</td>
          <td>真实距离<i>$D_o$</i>，mm</td>
          <td>偏差E，%</td>
        </tr>
        <tr>
          <td>水平</td>
          <td><el-input v-model="form5.testLengthLevel" /></td>
          <td><el-input v-model="form5.readLengthLevel" /></td>
          <td class="result"><el-input v-model="form5.deviationLevel" disabled/></td>
        </tr>
        <tr>
          <td>垂直</td>
          <td><el-input v-model="form5.testLengthVertical" /></td>
          <td><el-input v-model="form5.readLengthVertical" /></td>
          <td class="result"><el-input v-model="form5.deviationVertical" disabled/></td>
        </tr>
      </table>
    </div>

    <!-- 7.IP擦除完全性:------------------------------------------------------------------------ -->
    <div id="table6">
      <div class="innertitle">
        7.IP擦除完全性:
        （<el-checkbox v-model="form6.notHaveState">状态检测无此项</el-checkbox>）
      </div>
      <div class="tip-30">
        预置条件:
        <el-input v-model="form6.tubeVoltage" class="input-line"/>kV
        <span style="margin-left: 50px;">SID：</span>
        <el-input v-model="form6.sid" class="input-line"/>cm
        <span style="margin-left: 50px;">附加滤过:</span>
        <el-input v-model="form6.extraFiltration" class="input-line"/>
      </div>
      <div class="tip-30">
        IP尺寸（in）：
        <el-input v-model="form6.dimension_width" class="input-line"/> x 
        <el-input v-model="form6.dimension_height" class="input-line"/>
        IP板序列编号：
        <el-input v-model="form6.boardNumber" class="input-line"/>
      </div>
      <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
        <tr>
          <td>预置条件mAs</td>
          <td>入射剂量μGy</td>
          <td>3mm厚Pb板</td>
          <td>Pb板幻影</td>
          <td>暗噪声指示值</td>
          <td>厂家保证值</td>
        </tr>
        <tr>
          <td><el-input v-model="form6.milliampereSecond_1" /></td>
          <td><el-input v-model="form6.measurementValue_1" /></td>
          <td>放置</td>
          <td><el-input v-model="form6.boardPhantom" /></td>
          <td><el-input v-model="form6.darkNoise" /></td>
          <td><el-input v-model="form6.guaranteedValue" /></td>
        </tr>
        <tr>
          <td><el-input v-model="form6.milliampereSecond_2" /></td>
          <td><el-input v-model="form6.measurementValue_2" /></td>
          <td>无</td>
          <td>
            <el-radio v-model="form6.boardPhantom_2" :label="true">有</el-radio>
            <el-radio v-model="form6.boardPhantom_2" :label="false">无</el-radio>
          </td>
          <td>二次擦除后暗噪声：<el-input v-model="form6.afterErasingDarkNoise" class="input-line" /></td>
          <td>暗噪声：<el-input v-model="form6.darkNoise" class="input-line" /></td>
        </tr>
      </table>
    </div>

    <!-- 8.高对比度分辨力:------------------------------------------------------------------------ -->
    <div id="table7">
      <div class="innertitle">
        8.高对比度分辨力:
      </div>
      <div class="tip-30">
        预置条件:
        <el-input v-model="form7.tubeVoltage" class="input-line"/>kV
        <el-input v-model="form7.tubeCurrent" class="input-line"/>mAs
        <span style="margin-left: 50px;">SID：</span>
        <el-input v-model="form7.sid" class="input-line"/>cm
        <span style="margin-left: 50px;">附加滤过:</span>
        <el-input v-model="form7.extraFiltration" class="input-line"/>
      </div>
      <div class="tip-30">
        IP尺寸（in）：
        <el-input v-model="form7.dimension_width" class="input-line"/> x 
        <el-input v-model="form7.dimension_height" class="input-line"/>
        IP板序列编号：
        <el-input v-model="form7.boardNumber" class="input-line"/>
      </div>
      <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
        <tr>
          <td>分辨力卡方向</td>
          <td>最大可分辨的线对数目，lp/mm</td>
          <td>厂家规定值lp/mm</td>
          <td>相对值%</td>
          <td><i>$f_{Nyquist}lp/mm$</i></td>
          <td>相对值%</td>
          <td>基线值lp/mm</td>
          <td>相对值%</td>
        </tr>
        <tr>
          <td>45°</td>
          <td><el-input v-model="form7.maximumResolvable" /></td>
          <td><el-input v-model="form7.manufactorValue" /></td>
          <td><el-input v-model="form7.factoryRelativeValues_1" /></td>
          <td><el-input v-model="form7.f_value" /></td>
          <td><el-input v-model="form7.factoryRelativeValues_2" /></td>
          <td><el-input v-model="form7.baselineValue" /></td>
          <td><el-input v-model="form7.factoryRelativeValues_3" /></td>
        </tr>
      </table>
    </div>

    <!-- 9.低对比度分辨力:------------------------------------------------------------------------ -->
    <div id="table8">
      <div class="innertitle">
        9.低对比度分辨力:
      </div>
      <div class="tip-30">
        预置条件:
        <el-input v-model="form8.tubeVoltage" class="input-line"/>kV
        <el-input v-model="form8.tubeCurrent" class="input-line"/>mAs
        <span style="margin-left: 50px;">SID：</span>
        <el-input v-model="form8.sid" class="input-line"/>cm
        <span style="margin-left: 50px;">附加滤过:</span>
        <el-input v-model="form8.extraFiltration" class="input-line"/>
      </div>
      <div class="tip-30">
        IP尺寸（in）：
        <el-input v-model="form8.dimension_width" class="input-line"/> x 
        <el-input v-model="form8.dimension_height" class="input-line"/>
        IP板序列编号：
        <el-input v-model="form8.boardNumber" class="input-line"/>
      </div>
      <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 100%;">
        <tr>
          <td>预置曝光条件</td>
          <td>可探测到最小细节</td>
          <td>基线值</td>
          <td>偏离</td>
        </tr>
        <tr>
          <td>约10μGy</td>
          <td>10mm孔径第<el-input v-model="form8.aperture_10mm" class="input-line" />个孔</td>
          <td>第<el-input v-model="form8.aperture_baseline" class="input-line" />个孔</td>
          <td><el-input v-model="form8.deviate" /></td>
        </tr>
      </table>
    </div>
  </div>
</template>

<script>
import {
  getInfoById,
  darkNoise,
  detectorDoseIndication,
  responseUniformityArtifact,
  response,
  rangeError,
  eraseCompleteness,
  contrastResolutionHigh,
  contrastResolutionLow
} from '@/api/testItem/item07'

export default {
  name: 'testItem07',
  props: {
    // tab栏
    activeNameEquipment: {
      type: String,
      default: '0',
    },
    // 基本信息数据
    basicForm: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      itemsId: null,
      // 1.IP暗噪声
      form1: {},
      form2: {},
      form3: {},
      form4: {},
      form5: {},
      form6: {},
      form7: {},
      form8: {},
    }
  },
  watch: {
    activeNameEquipment: {
      handler(newv) {
        this.getDataDetailById()
      },
      deep: true,
      immediate: true
    },
  },
  methods: {
    // 获取数据
    getDataDetailById() {
      this.$nextTick(()=> {
        getInfoById(this.basicForm.resultId).then(response => {
          this.itemsId = response.data.itemsId || ''
          // 1.IP暗噪声:
          this.form1 = response.data.darkNoise || {}
          this.form2 = response.data.detectorDoseIndication || {}
          this.form3 = response.data.responseUniformityArtifact || {}
          this.form4 = response.data.response || {}
          this.form5 = response.data.rangeError || {}
          this.form6 = response.data.eraseCompleteness || {}
          this.form7 = response.data.contrastResolutionHigh || {}
          this.form8 = response.data.contrastResolutionLow || {}
        }).catch(err => this.$emit('loadingchange', true))
        // 绑定请求
        let itemsLength = 8
        for (let index = 0; index < itemsLength; index++) {
          let tableInputs = Array.from(document.getElementById(`table${index + 1}`)?.getElementsByTagName('input'))
          for (let i = 0; i < tableInputs.length; i++) {
            this.bind(tableInputs[i], () => {
              this.submitTestForm(index + 1)
            })
          }
        }
      })
    },
    // 保存数据
    submitTestForm(index) {
      this.$emit('loadingchange', true)
      this[`form${index}`].itemsId = this.itemsId
      switch (index) {
        // 1.IP暗噪声
        case 1:
          darkNoise(this.form1).then((response) => {
            response.data ? this.form1 = response.data : {}
            this.$emit('loadingchange', false)
          })
          break;
        // 2.探测器剂量指示(DDI)
        case 2:
          detectorDoseIndication(this.form2).then((response) => {
            response.data ? this.form2 = response.data : {}
            this.$emit('loadingchange', false)
          })
          break;
        // 3.IP响应均匀性、4.IP响应一致性
        case 3:
          responseUniformityArtifact(this.form3).then((response) => {
            response.data ? this.form3 = response.data : {}
            this.$emit('loadingchange', false)
          })
          break;
        // 5.IP响应线性
        case 4:
          response(this.form4).then((response) => {
            response.data ? this.form4 = response.data : {}
            this.$emit('loadingchange', false)
          })
          break;
        // 6.测距误差
        case 5:
          rangeError(this.form5).then((response) => {
            response.data ? this.form5 = response.data : {}
            this.$emit('loadingchange', false)
          })
          break;
        // 7.IP擦除完全性
        case 6:
          eraseCompleteness(this.form6).then((response) => {
            response.data ? this.form6 = response.data : {}
            this.$emit('loadingchange', false)
          })
          break;
        // 8.高对比度分辨力
        case 7:
          contrastResolutionHigh(this.form7).then((response) => {
            response.data ? this.form7 = response.data : {}
            this.$emit('loadingchange', false)
          })
          break;
        // 9.高对比度分辨力
        case 8:
          contrastResolutionLow(this.form8).then((response) => {
            response.data ? this.form8 = response.data : {}
            this.$emit('loadingchange', false)
          })
          break;
      }
    },
  },
}
</script>

<style lang="scss" scoped>
@import "../content.scss";
</style>